
package movies;

import org.apache.sling.api.resource.Resource;

public abstract class Movies {
    public final static int rootDepth = 2;

    public static Resource getRoot(final Resource resource) {
        Resource rootResource = resource;
        if (resource != null) {
            int depth = resource.getPath().split("/").length;
            for (int i = depth - Movies.rootDepth; i > 1; --i) {
                rootResource = rootResource.getParent();
            }
        }
        return rootResource;
    }

}
